package com.example.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

import static com.example.util.FileEncryptionUtil.decryptFile;

public class FileReceiver {

    public static String receiveFile(Socket clientSocket) throws IOException {
        InputStream inputStream = clientSocket.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String encryptedFile = reader.readLine();
        return encryptedFile;
    }

    public static String decryptAndSaveFile(String filePath) {
        String decryptedFilePath = decryptFile(filePath);
        System.out.println("文件接收并解密完成：" + decryptedFilePath);
        return decryptedFilePath;
    }
}
